﻿Type=Activity
Version=5.8
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.
	Private ulvmyeval As UltimateListView
	Private pmodify As Panel
	Private itemteachername As Label
	Private itemtimedetail As Label
	Private itemriv As RIV
	Private itemchatcontent As Label
	Dim lstData As List
	Private Label1 As Label
	Private Label2 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("laymyevallist")
	initviews
End Sub
Sub initviews
	lstData.Initialize
	'comm.setFA(Label1,"fa-pencil","追加")
	Dim nh As Int=170dip
	ulvmyeval.AddLayout("itemmyeval","itemmyeval_LayoutCreator","itemmyeval_ContentFiller",nh,False)
'	For i=0 To 9
'		lstData.Add(i)
'		ulvmyeval.AddItem("itemmyeval",i)
'	Next
	reqmyratelst
End Sub
Private Sub parseMyrate(str As String)
	Dim parser As JSONParser 
	parser.Initialize(str) 
	Dim root As Map = parser.NextObject 
	Dim data As List = root.Get("data") 
	lstData.Clear
	For Each coldata As Map In data 
	    Dim image As String = coldata.Get("image") 
	    Dim comment_xj As String = coldata.Get("comment_xj") 
	    Dim city As String = coldata.Get("city") 
	    Dim kc_title As String = coldata.Get("kc_title") 
	    Dim comment_addtime As String = coldata.Get("comment_addtime") 
	    Dim usertel As String = coldata.Get("usertel") 
	    Dim comment_id As String = coldata.Get("comment_id") 
	    Dim nianji As String = coldata.Get("nianji") 
	    Dim comment_huifu_id As String = coldata.Get("comment_huifu_id") 
	    Dim kc_id As String = coldata.Get("kc_id") 
	    Dim children As String = coldata.Get("children") 
	    Dim comment_type As String = coldata.Get("comment_type") 
	    Dim riqi As String = coldata.Get("riqi") 
	    Dim js_id As String = coldata.Get("js_id") 
	    Dim comment_content As String = coldata.Get("comment_content") 
	    Dim id As String = coldata.Get("id") 
	    Dim jsname As String = coldata.Get("jsname") 
	    Dim username As String = coldata.Get("username") 
		Dim rit As rateItem
		rit.Initialize
		rit.id=id
		rit.content=comment_content
		rit.contentTime=comment_addtime
		rit.kcname=kc_title
		rit.ordTime=riqi
		rit.ratetype=comment_type
'		If comment_type.EqualsIgnoreCase("1") Then
'			rit.ratetype="好评"
'		else if comment_type.EqualsIgnoreCase("2") Then
'			rit.ratetype="中评"
'		Else
'			rit.ratetype="差评"
'		End If
		rit.teachheadimg=comm.combinPic(image)
		rit.teachname=jsname
		lstData.Add(rit)
		ulvmyeval.AddItem("itemmyeval",lstData.Size-1)
	Next 
	Dim status As String = root.Get("status") 
	'ulvmyeval.RefreshContent

End Sub
Sub JobDone(thj As HttpJob)
	ProgressDialogHide
	If thj.Success Then
		Dim str As String=thj.GetString
		Dim nr As netRes=ParseHelper.getStatusData(str)
		If nr.nCode==200 Then
			parseMyrate(str)
		Else
			comm.TL("错误:"&nr.sData)
		End If
	Else
		comm.TL("网络错误:"&thj.JobName&thj.ErrorMessage)
	End If
	thj.Release
End Sub
Private Sub reqmyratelst
	comm.showProgress("正在获取数据")
	ParseHelper.doGetReq(Me,"reqrate",comm.getApi(comm.apiIdx.REQMYRATE),Null)
End Sub
Sub itemmyeval_LayoutCreator(LayoutName As String, LayoutPanel As Panel)
	LayoutPanel.LoadLayout(LayoutName)
End Sub
Sub itemmyeval_ContentFiller(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
	Dim p As Panel=LayoutPanel.GetView(0)
	Dim mdp As Panel=p.GetView(3)
	p=p.GetView(0)
	Dim tecriv As RIV=p.GetView(0)
	Dim rit As rateItem=lstData.Get(ItemID)
	If rit.teachheadimg.Length>0 Then
		comm.loadimg(rit.teachheadimg,tecriv)
	Else
		comm.loadimg(comm.S_TESTMYHEADER,tecriv)	
	End If
	mdp.Tag=ItemID
	itemteachername.Text=rit.teachname
	comm.setFA(Label1,"fa-pencil","追加")
	setratetype(rit.ratetype,Label2)
	itemtimedetail.Text=$"课程：${rit.kcname}
时间：${rit.ordTime}"$
	itemchatcontent.Text=rit.content&CRLF&rit.contentTime
End Sub
Private Sub setratetype(n As Int,lbl As Label)
	Dim sHeart As String="fa-heart"
	Select n
	Case 1
		comm.setFA(lbl,sHeart," 好评")
		lbl.Textcolor=Colors.Red
	Case 2
		comm.setFA(lbl,sHeart," 中评")
		lbl.Textcolor=0xFFFF9C00
	Case 3
		comm.setFA(lbl,sHeart," 差评")
		lbl.Textcolor=Colors.Black
	End Select
End Sub
Sub Activity_Resume
	
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub ivback_Click
	Activity.Finish
End Sub
'追加评价
Sub pmodify_Click
	Dim p As Panel=Sender
	Log(p.Tag)
	StartActivity(actModifyEval)
End Sub